﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SqlSugar;
using SH.Common.DataDictionary;
using FluentValidation;
using SH.Multitenant.Domain.RBAC;

namespace SH.Multitenant.Domain.Multitenant
{
    [TenantAttribute("multitenant")]
    public class User : Tenant
    {
        /// <summary>
        /// 用户编号
        /// </summary>
        [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
        public int UId { get; set; }
        /// <summary>
        /// 用户名
        /// </summary>
        [SugarColumn(ColumnDataType = "Nvarchar(50)", IsNullable = false)]
        public string? UName { get; set; }
        /// <summary>
        /// 密码
        /// </summary>
        [SugarColumn(ColumnDataType = "Nvarchar(50)", IsNullable = false)]
        public string? UPwd { get; set; }
        /// <summary>
        /// 错误次数
        /// </summary>
        public int ErrorTimes { get; set; } = 0;
        /// <summary>
        /// 是否锁定 true已锁 false未锁
        /// </summary>
        public bool IsLocked { get; set; }
        /// <summary>
        /// 锁定时间
        /// </summary>
        public DateTime? LockTime { get; set; }
        //public string? TenantId { get; set; }
    }
    public class UserValidator : AbstractValidator<User>
    {
        public UserValidator()
        {
            RuleFor(x => x.UName).NotEmpty().MaximumLength(50);
            RuleFor(x => x.UPwd).NotEmpty().MaximumLength(50);

        }
    }
}
